<template>
  <basic-container class="invoiceback">
    <div class="invoicefifter">
      <el-form :inline="true" :model="invoiceform">
        <el-form-item label="后台单号:">
          <el-input placeholder="请输入后台单号" v-model.trim="invoiceform.orderNo" size="small" clearable
            @keyup.enter.native='handleFilter(Launchdate)'>
          </el-input>
        </el-form-item>
        <el-form-item label="税号:">
          <el-input placeholder="请输入税号" v-model.trim="invoiceform.invoiceNo" size="small" clearable
            @keyup.enter.native='handleFilter(Launchdate)'>
          </el-input>
        </el-form-item>
        <el-form-item label="发票号:">
          <el-input placeholder="请输入发票号" v-model.trim="invoiceform.invoiceNum" size="small" clearable
                    @keyup.enter.native='handleFilter(Launchdate)'>
          </el-input>
        </el-form-item>
        <el-form-item label="手机号:">
          <el-input placeholder="请输入手机号" v-model.trim="invoiceform.phone" size="small" clearable
            @keyup.enter.native='handleFilter(Launchdate)'>
          </el-input>
        </el-form-item>
        <el-form-item label="邮箱:">
          <el-input placeholder="请输入邮箱" v-model.trim="invoiceform.email" size="small" clearable
                    @keyup.enter.native='handleFilter(Launchdate)'>
          </el-input>
        </el-form-item>
        <el-form-item label="城市:">
          <el-select v-model.trim="invoiceform.deptId" size="small" clearable placeholder="请选择城市"
            @visible-change='getdeptdepts' ref='cityIdRef' @keydown.native="selectBlur($event)">
            <el-option v-for="item in cityList" :key="item.id" size="small" :label="item.deptName" :value="item.id">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="审核状态:">
          <el-select v-model.trim="invoiceform.status" size="small" clearable placeholder="请选择审核状态"
                      @keydown.native="selectBlur($event)">
            <el-option v-for="item in statusList" :key="item.dictKey" size="small" :label="item.dictValue"
              :value="item.dictKey">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="提交日期">
          <el-date-picker v-model="Launchdate" type="daterange" size="small" range-separator="至" start-placeholder="开始日期"
            :clearable='false' end-placeholder="结束日期">
          </el-date-picker>
        </el-form-item>
        
        <el-form-item label="渠道类别" style="margin-bottom: 15px!important;margin-left: 10px;">
          <el-select ref="channelTypeRef" v-model="invoiceform.channelType" clearable filterable size="medium" placeholder="渠道类别" style="width: 155px" @keydown.native="keydown($event)">
            <el-option v-for="(channelItem,channel) in channelTypeList" :key="channel" :label="channelItem.channelName"
              :value="channelItem.channelKey">
              <span :data-id="channelItem.id" style="display: inline-block;width: 150px;padding: 0 20px;margin-left: -20px;"
                @click="getChannelTypeId($event)">{{ channelItem.channelName }}</span>
            </el-option>
          </el-select>
        </el-form-item>
        
        <el-form-item label="渠道" style="margin-bottom: 15px!important;">
          <el-select ref="channelRef" v-model="invoiceform.channel" clearable filterable size="medium" placeholder="渠道" style="width: 155px" @keydown.native="keydown($event)">
            <el-option v-for="(channelItem,channel) in channerList" :key="channel" :label="channelItem.channelName"
              :value="channelItem.channelKey"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="金额:">   
            <el-input 
                v-model.trim="invoiceform.lowPrice"
                placeholder="最低金额"
                size="small" 
                @blur="priceBlur('lowPrice')"
                clearable
                style="width:150px"
            />
            至
            <el-input 
                v-model.trim="invoiceform.highPrice"
                placeholder="最高金额"
                size="small" 
                @blur="priceBlur('highPrice')"
                clearable
                style="width:150px"
            />
        </el-form-item>
        <el-form-item label="订单状态" style="margin-right: 15;margin-bottom: 15px!important;">
          <el-select
            ref="statusRef"
            v-model="invoiceform.orderStatus"
            clearable
            size="medium"
            placeholder="状态"
            style="width: 130px"
            @keydown.native="selectBlur($event)"
          >
            <el-option
              v-for="item in orderStatusList"
              :key="item.status"
              :label="item.statusName"
              :value="item.status"
            />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" plain size="small" icon="el-icon-search" @click="handleFilter(Launchdate)">查询</el-button>
          <el-button style="margin-left: 20px" type="primary" plain size="small" icon="el-icon-download" @click="handleExport()">导出</el-button>
          <el-button style="margin-left: 20px" type="primary" plain size="small" @click="openOneClick">一键审核</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div >
      <el-table :data="orderInvoiceList" style="width: 100%">
        <el-table-column label="多选">
            <template slot-scope="scope">
                <el-checkbox-group  v-model="scope.row.checked" @change="allNotReviewed(scope.row)" >
                    <el-checkbox ></el-checkbox>
                </el-checkbox-group>
            </template>
        </el-table-column>
        <el-table-column prop="deptName" label="城市" align="left" min-width="80"/>
        <el-table-column prop="mainWarehouse" label="总仓" align="left" min-width="80"/>
        <el-table-column prop="branchWarehouse" label="分仓" align="left" min-width="80"/>
        <el-table-column prop="orderNo" label="后台单号" align="left" min-width="140"/>
        <el-table-column prop="platformOrderId" label="平台单号" align="left" min-width="180"/>
        <el-table-column prop="orderStatus" label="订单状态" align="left" min-width="80"/>
        <el-table-column prop="channelName" label="渠道名称" align="left" min-width="80"/>
        <el-table-column prop="invoiceTitle" label="发票抬头" align="left" min-width="180"/>
        <el-table-column prop="invoiceNo" label="税号" align="left" min-width="180"/>
        <el-table-column prop="invoiceNum" label="发票号" align="left" min-width="180"/>
        <el-table-column prop="phone" label="手机号" align="left" min-width="120"/>
        <el-table-column prop="email" label="邮箱" align="left" min-width="140"/>
        <el-table-column prop="totalPrice" label="订单总额" align="left" min-width="80">
          <template slot-scope="scope">
            <span>{{scope.row.totalPrice/100}}</span>
          </template>
        </el-table-column>
        <el-table-column prop="totalPrice" label="发票金额" align="left" min-width="80">
          <template slot-scope="scope">
            <span>{{scope.row.invoiceTotalPrice/100}}</span>
          </template>
        </el-table-column>
        <el-table-column prop="mergeFlag" label="是否合并" min-width="70" align="center">
          <template slot-scope="scope">
            <el-button size="small" type="success" plain v-if="scope.row.mergeFlag=='1'">是</el-button>
            <el-button size="small" type="danger" plain v-if="scope.row.mergeFlag=='0'">否</el-button>
          </template>
        </el-table-column>

        <el-table-column prop="status" label="审核状态" min-width="70" align="center">
          <template slot-scope="scope">
            <el-button size="small" type="info" plain >{{getStatusName(scope.row.status)}}</el-button>
          </template>
        </el-table-column>

        <el-table-column label="提交时间" min-width="160" align="center">
          <template slot-scope="scope">
            <span v-if='scope.row.createTime'>{{scope.row.createTime}}</span>
            <span v-else>-</span>
          </template>
        </el-table-column>
        <el-table-column prop="serviceName" label="客服审核人" align="left" min-width="80"/>
        <el-table-column prop="serviceTime" label="客服审核时间" align="left" min-width="160"/>
        <el-table-column prop="serviceRemark" label="客服审核备注" align="left" min-width="160"/>
        <el-table-column prop="approvalTime" label="财务审核时间" min-width="160" align="center">
          <template slot-scope="scope">
            <span v-if='scope.row.approvalTime'>{{scope.row.approvalTime}}</span>
            <span v-else>-</span>
          </template>
        </el-table-column>
        <el-table-column label="财务审核人" min-width="50" align="center">
          <template slot-scope="scope">
            <span v-if='scope.row.approvalName'>{{scope.row.approvalName}}</span>
            <span v-else>-</span>
          </template>
        </el-table-column>
        <el-table-column prop="remarks" label="财务备注" align="left" min-width="160"/>

        <el-table-column label="操作" align="center" fixed="right" min-width="120">
          <template slot-scope="scope">
            <div class="operate-btns">
              <el-button type="success" size="small" @click='handleAudit(scope.row)'
                        v-if="(scope.row.status==0 && permissionList.invoice_service_approve)
                        || (scope.row.status==1  && permissionList.invoice_finance_approve)">审核</el-button>
              <el-button type="primary" size="small" @click='viewLog(scope.row)'>日志</el-button>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <pagination v-show="total>0" :total="total" :page.sync="invoiceform.page" :limit.sync="invoiceform.size"
        layout="sizes,prev, pager, next,total" @pagination="getInvoiceList" />
    </div>

    <!--审核-->
    <el-dialog title="审核" center :visible.sync="dialoginvoice" class="dialoginvoice">
      <el-form>
        <el-form-item label="审核:" :label-width="formLabelWidth">
          <el-radio  v-for="item in statusList" :key="item.dictKey"
                     v-if="(updateForm.vstatus == 0 && item.dictKey < 3) || (updateForm.vstatus == 1 && item.dictKey > 2)" :label="item.dictKey" v-model="updateForm.status" >
            {{ item.dictValue }}</el-radio>
        </el-form-item>

        <el-form-item label="渠道名称" :label-width="formLabelWidth" >
          <el-input  resize='none' type="text" disabled="disabled"
                     v-model.trim="updateForm.vchannelName" maxlength="64" show-word-limit>
          </el-input>
        </el-form-item>
        <el-form-item label="平台单号" :label-width="formLabelWidth" >
          <el-input  resize='none' type="text" disabled="disabled"
                     v-model.trim="updateForm.vplatformOrderId" maxlength="64" show-word-limit>
          </el-input>
        </el-form-item>
        <el-form-item label="订单金额" :label-width="formLabelWidth" >
          <el-input  resize='none' type="number" disabled="disabled"
                     v-model.trim="updateForm.vtotalPrice" maxlength="64" show-word-limit>
          </el-input>
        </el-form-item>
        <el-form-item label="发票金额" :label-width="formLabelWidth" >
          <el-input  resize='none' type="number"
                     :disabled="updateForm.vstatus==1"
                     v-model.trim="updateForm.invoiceTotalPrice" maxlength="64" show-word-limit>
          </el-input>
        </el-form-item>
        <el-form-item label="抬头" :label-width="formLabelWidth" >
          <el-input  resize='none' type="text"
                     :disabled="updateForm.vstatus==1"
                     v-model.trim="updateForm.invoiceTitle" maxlength="64" show-word-limit>
          </el-input>
        </el-form-item>
        <el-form-item label="税号" :label-width="formLabelWidth" >
          <el-input  resize='none' type="text"
                     :disabled="updateForm.vstatus==1"
                     v-model.trim="updateForm.invoiceNo" maxlength="64" show-word-limit>
          </el-input>
        </el-form-item>
        <el-form-item label="邮箱" :label-width="formLabelWidth" >
          <el-input  resize='none' type="text"
                     :disabled="updateForm.vstatus==1"
                     v-model.trim="updateForm.email" maxlength="64" show-word-limit>
          </el-input>
        </el-form-item>
        <el-form-item v-if="updateForm.vstatus==1" label="发票号" :label-width="formLabelWidth" >
          <input type="text" class="el-input__inner" v-model="updateForm.invoiceNum">
        </el-form-item>
        <el-form-item label="备注" :label-width="formLabelWidth" >
          <el-input  resize='none' type="textarea" :placeholder="passText"
                    v-model.trim="updateForm.remarks" maxlength="64" show-word-limit>
          </el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="orderInvoiceApproveSummit()">提交</el-button>
        <el-button @click="dialoginvoice = false">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 一键审核 -->
    <el-dialog title="审核" center :visible.sync="oneClickDialog" class="dialoginvoice">
        <el-form>
            <!-- 状态 -->
            <el-form-item label="审核:" :label-width="formLabelWidth">
                <el-radio  
                    v-for="item in statusList" 
                    :key="item.dictKey"
                    v-if="(updateForm.vstatus == 0 && item.dictKey < 3) || (updateForm.vstatus == 1 && item.dictKey > 2)" :label="item.dictKey" v-model="updateForm.status"
                >
                {{ item.dictValue }}
                </el-radio>
            </el-form-item>
            <!-- 备注 -->
            <el-form-item label="备注" :label-width="formLabelWidth ">
                <el-input  resize='none' type="textarea" :placeholder="passText"
                            v-model.trim="choiceRemarks" maxlength="64" show-word-limit>
                </el-input>
            </el-form-item>
        </el-form>
        <!-- 按钮 -->
        <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="oneClickReview">提交</el-button>
            <el-button @click="exitMultiple">取 消</el-button>
        </div>
    </el-dialog>

    <!--  日志  -->
    <el-dialog title="日志" center :visible.sync="log.dialogLog" class="dialoginvoice">
      <div v-html="log.logText"></div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="log.dialogLog = false">取 消</el-button>
      </div>
    </el-dialog>

  </basic-container>
</template>

<script>
 import { statusList,} from "@/api/pending";
  import Pagination from "@/components/Pagination";
  import { getOrderChannelList,getOrderChannelTypeList } from '@/api/createOrder'; // 渠道
  import {
    //接口
    orderInvoiceStatus, //审核状态
    deptdepts, //城市
    orderInvoiceApprove, //审核
    orderInvoiceQueryPage, //列表
    orderInvoiceApproveBatch // 一键审核
  } from "@/api/workorder"
 
  import {mapGetters} from "vuex";
import { Ls } from "dayjs";
  export default {
    data() {
      return {
        invoiceform: {
          orderNo: null, //平台单号
          deptId: null, //城市
          startTime: this.dayjs(
              new Date()
            )
            .format("YYYY-MM-DD")
            .toString(), //提交的开始时间
          endTime: this.dayjs(
              new Date()
            )
            .format("YYYY-MM-DD")
            .toString(), //提交的结束时间
          invoiceNo: null, //税号
          phone: null, //手机号
          page: 1,
          size: 10,
          channelType: '',// 渠道类别
          channel: '', // 渠道
          orderStatus: '',  // 订单状态
          lowPrice: '',   // 最低金额
          highPrice: '',  // 最高金额
          
        },
        updateForm: {
          status: 0,
          vstatus: 0,
          invoiceTotalPrice: 0,
          invoiceTitle: '',
          invoiceNo: '',
          email: '',
          remarks: ''
        },
        log: {
          dialogLog: false,
          logText: '',
        },
        channelTypeList: [], // 渠道类别列表
        channerList: [],
        getChannelList: { // 渠道列表
            parentId: ''
        },
        total: 0,
        orderInvoiceList: [],
        // 弹层
        formLabelWidth: '120px',
        dialoginvoice: false,
        oneClickDialog: false, // 一键审核弹窗
        cityList: [],
        statusList: [], //审核状态
        orderStatusList: [], // 订单状态
        Launchdate: [
          this.dayjs(
            new Date()
          )
          .format("YYYY-MM-DD")
          .toString(),
          this.dayjs(
            new Date()
          )
          .format("YYYY-MM-DD")
          .toString(),
        ],
        choiceArr : [],
        passText: '请输入审核不通过原因',
        choiceRemarks: '' // 一键审批备注
      }
    },

    components: {
      Pagination
    },
    mounted() {
        this.orderInvoiceStatusList();
        this.getInvoiceList();
        this.getOrderStatus()
        // 渠道类别
        getOrderChannelTypeList().then(res => {
            this.channelTypeList = res.data.data;
        }) 
    },
    destroyed() {
      window.removeEventListener("keydown", this.keyDown, false);
    },
    computed: {
      ...mapGetters(["permission"]),
      permissionList() {
        return {
          invoice_service_approve: this.vaildData(this.permission.invoice_service_approve, false),
          invoice_finance_approve: this.vaildData(this.permission.invoice_finance_approve, false),
        };
      }
    },
    methods: {
        // 获取订单状态列表
        async getOrderStatus() {
            const res = await statusList()
            this.orderStatusList = res.data.data || []
        },
        openOneClick() {
            if(this.choiceArr.length <= 0 ) {
                this.$message({
                    type: "warning",
                    message: "请先选择订单!"
                })
                return
            }
            this.oneClickDialog = true
        },
        // 提交一键审核
        async oneClickReview() {
            this.choiceArr.forEach(item=> {
                item.remarks = this.choiceRemarks
                item.status = this.updateForm.status
            })
            if(this.updateForm.status <= 0) {
                this.$message({
                    type: "warning",
                    message: "请选择审核状态!"
                })
                return
            } 
            const res = await orderInvoiceApproveBatch(this.choiceArr)
            if(res.data.code == 200 && res.data.msg == "操作成功" ) {
                this.$message({
                    type: "success",
                    message: "提交审核成功!"
                })
                this.exitMultiple
                this.getInvoiceList()
            }else {
                this.$message({
                    type: "warning",
                    message: "提交审核失败!"
                })
            }
        },
        // 退出一键审核
        exitMultiple() {
            this.oneClickDialog = false
            this.choiceRemarks = ''
            this.orderInvoiceList.forEach(item=> item.checked = false)
            this.choiceArr = []
            this.updateForm.status = 0
        },
        // 多选
        allNotReviewed(row) {
            let choiceObj =  {  
                id: 0,    
                email:'',      
                status:'',
                remarks:'',      
                invoiceNo:'',      
                invoiceNum:'',    
                invoiceTitle:'',  
                invoiceTotalPrice: 0,  
            } 
            if(row.status > 1) {
                 this.$message({
                    type: "warning",
                    message: "所选订单已无需审批!"
                })
                row.checked = false
                return 
            }
            this.updateForm.vstatus = row.status
            var needDel = this.choiceArr.filter(sub=> sub.id == row.id)
            if(row.checked) {
                // 判断所勾选列表是否都是一样的审核状态
                var similar = this.choiceArr.every(item=> item.status == row.status)
                if(!similar) {
                        this.$message({
                        type: "warning",
                        message: "请选择审核状态相同的订单!"
                    })
                    row.checked = false
                    return 
                }  
                // 防止重复加入
                if(needDel.length && this.choiceArr.includes(needDel)) {
                    return 
                }else {
                    Object.keys(choiceObj).forEach(key=> {
                        choiceObj[key] = row[key] || choiceObj[key]
                    })
                    this.choiceArr.push(choiceObj)
                }
            }else {
                if(needDel.length) this.choiceArr.splice(this.choiceArr.indexOf(needDel[0]), 1)
            } 
        },
         // 选择渠道类型
        getChannelTypeId(e) {
            this.getChannelList.parentId = e.currentTarget.dataset.id;
            // 渠道列表接口
            getOrderChannelList(this.getChannelList).then(res => {
            let result = res.data.data;
            result.forEach(item => {
                this.channerList = result;
                if (this.invoiceform.channel !== undefined) {
                if (item.channelKey == this.invoiceform.channel) {
                    this.channerList = result;
                } else {
                    this.channerList = result;
                    this.invoiceform.channel = '';
                }
                }
            })
            })
        },            
        // 查询金额发生改变
        priceBlur(type) {
            if(type == 'lowPrice') {
                if (!this.invoiceform.lowPrice) return 
                this.invoiceform.highPrice = (Number(this.invoiceform.lowPrice) + 50) + ''
            }else {
                if(this.invoiceform.highPrice <= 0 )  return
                const minimum = (Number(this.invoiceform.highPrice) - 50 )
                this.invoiceform.lowPrice = (minimum > 0 ? minimum : 0) + ''
            }
        },
      // 选择框回车失焦
      selectBlur(e) {
        if (e.keyCode == 13) {
          this.$refs['cityIdRef'].blur();
          e.returnValue = false;
        }
      },
      // 回车事件
      keyupEnter() {
        if (this.dialoginvoice == false) {
          if (window.event.keyCode == 13) {
            this.handleFilter(this.Launchdate); // 查询事件
          }
        }else{
          window.removeEventListener("keydown", this.keyDown, false);
        }
      },
      //如果页面有keep-alive缓存功能，这个函数会触发
      activated() {
        window.addEventListener("keydown", this.keyupEnter);
      },
      deactivated() {
        window.removeEventListener("keydown", this.keyupEnter);
      },
      // 查询下拉部分---------------------------------------------------------

      orderInvoiceStatusList() {
        orderInvoiceStatus().then(res => {
          this.statusList = res.data.data
        })
      },
      getStatusName(key) {
       let statusArr=this.statusList.filter(item=>{
          if (item.dictKey==key){
            return item;
          }
        })
        if (statusArr.length>0){
          return statusArr[0].dictValue;
        }
      },
      getdeptdepts() { //
        deptdepts().then(res => {
          this.cityList = res.data.data
        })
      },
      getInvoiceList() { //获取列表数据
          if (this.invoiceform){
            if (!this.invoiceform.deptId){
              this.invoiceform.deptId=null;
            }
           if (!this.invoiceform.invoiceNo){
              this.invoiceform.invoiceNo=null;
            }
           if (!this.invoiceform.orderNo){
              this.invoiceform.orderNo=null;
            }
           if (!this.invoiceform.phone){
              this.invoiceform.phone=null;
            }
          }
          orderInvoiceQueryPage({
              ...this.invoiceform,
              lowPrice: (this.invoiceform.lowPrice) ? (this.invoiceform.lowPrice +'00') : undefined,
              highPrice: (this.invoiceform.highPrice) ? (this.invoiceform.highPrice +'00') : undefined,
          }).then(res => {
          this.orderInvoiceList = res.data.data.rows.map(item => {
              item.checked = false
              return item
          })
          this.total = res.data.data.total;
          this.exitMultiple()
        })
      },
      handleFilter(times) { //查询数据
        this.invoiceform.page = 1;
        if (times) {
          this.invoiceform.startTime = this.dayjs(
              times[0]
            )
            .format("YYYY-MM-DD")
            .toString();
          this.invoiceform.endTime = this.dayjs(
              times[1]
            )
            .format("YYYY-MM-DD")
            .toString();
        }
        var time1 = Date.parse(this.dayjs(
            times[0]
          )
          .format("YYYY-MM-DD 00:00:00")
          .toString());
        var time2 = Date.parse(this.dayjs(
            times[1]
          )
          .format("YYYY-MM-DD 00:00:00")
          .toString());
        //讲两个时间相减，求出相隔的天数
        var dayCount = Math.abs(time2 - time1) / 1000 / 60 / 60 / 24;
        if (dayCount >= 31) {
          this.$message({
            showClose: true,
            message: "时间间隔不可超过31天",
            type: "warning"
          });
        } else {
            this.getInvoiceList();
        }
      },
      //查看日志
      viewLog(row) {
        this.log.dialogLog = true;
        this.log.logText = row.log;
      },
      handleAudit(row) { //审核页面弹窗
        this.dialoginvoice = true;
        this.updateForm.id = row.id;
        this.updateForm.status = row.status;
        this.updateForm.vstatus = row.status;
        this.updateForm.invoiceTotalPrice = row.invoiceTotalPrice/100;
        this.updateForm.vtotalPrice = row.totalPrice/100;
        this.updateForm.vplatformOrderId = row.platformOrderId;
        this.updateForm.vchannelName = row.channelName;
        this.updateForm.invoiceTitle = row.invoiceTitle;
        this.updateForm.invoiceNo = row.invoiceNo;
        this.updateForm.invoiceNum = '';
        this.updateForm.email = row.email;
        this.updateForm.remarks = '';
      },
      orderInvoiceApproveSummit(formName) { //提交'
        var json = JSON.parse(JSON.stringify(this.updateForm));
        json.invoiceTotalPrice = new Number(json.invoiceTotalPrice * 100).toFixed(0);
        orderInvoiceApprove(json).then(res => {
          if (res.data.code == '200') {
            this.$message({
              type: "success",
              message: "提交审核成功!"
            });
            this.dialoginvoice = false
            this.getInvoiceList();
          } else {
            this.$message({
              type: "warning",
              message: "提交审核失败!"
            });

          }
        })
      },
      /**导出*/
      handleExport() {
          this.$confirm("确定导出当前条件下的数据？ 是否继续?", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          })
          .then(() => {
            var user = JSON.parse(localStorage.getItem('saber-userInfo'));
            var params = '&blade-auth=bearer ' + user['content'].accessToken;
            for (let invoiceformKey in this.invoiceform) {
              if(this.invoiceform[invoiceformKey] != null && this.invoiceform[invoiceformKey]!=='') {
                params+='&' + invoiceformKey + '=' + this.invoiceform[invoiceformKey];
              }
            }
            window.open('/api/xmbz-order/orderInvoice/export?' + params)
          })
          .catch(() => {

          });
      }

    },
    watch: {
        'updateForm.status':{
            handler(newVal) {
                newVal == 1 || newVal == 3 ?  this.passText = '请输入审核通过原因' : this.passText = '请输入审核不通过原因'
            },
            immediate: true,
            deep: true
        },
    }

  }
</script>

<style lang="scss" scoped>
  .invoiceback {
    padding: 10px;

    .invoicefifter {
      display: flex;

      .el-form-item {
        margin-bottom: 22px !important;
      }
    }

    .el-table .cell {
      padding: 0 2px !important;

      .el-button--small,
      .el-button--small.is-round {
        padding: 5px 3px !important;
      }
    }


    .dialoginvoice {
      .el-dialog__header {
        border-bottom: 1px solid #c7c6c6;
      }

    }

    .operate-btns {
      .el-button {
        padding: 10px;
        margin: 0 4px 0 0;
      }
    }
  }
</style>
